package com.ruoyi.peoplegroup.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.peoplegroup.domain.Researcherprojects;
import com.ruoyi.peoplegroup.service.IResearcherprojectsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 科研人员关联项目Controller
 * 
 * @author gw
 * @date 2025-01-08
 */
@RestController
@RequestMapping("/researcherprojects")
public class ResearcherprojectsController extends BaseController
{
    @Autowired
    private IResearcherprojectsService researcherprojectsService;

    /**
     * 查询科研人员关联项目列表
     */
    @RequiresPermissions("peoplegroup:researcherprojects:list")
    @GetMapping("/list")
    public TableDataInfo list(Researcherprojects researcherprojects)
    {
        startPage();
        List<Researcherprojects> list = researcherprojectsService.selectResearcherprojectsList(researcherprojects);
        return getDataTable(list);
    }

    /**
     * 导出科研人员关联项目列表
     */
    @RequiresPermissions("peoplegroup:researcherprojects:export")
    @Log(title = "科研人员关联项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Researcherprojects researcherprojects)
    {
        List<Researcherprojects> list = researcherprojectsService.selectResearcherprojectsList(researcherprojects);
        ExcelUtil<Researcherprojects> util = new ExcelUtil<Researcherprojects>(Researcherprojects.class);
        util.exportExcel(response, list, "科研人员关联项目数据");
    }

    /**
     * 获取科研人员关联项目详细信息
     */
    @RequiresPermissions("peoplegroup:researcherprojects:query")
    @GetMapping(value = "/{researcherProjectId}")
    public AjaxResult getInfo(@PathVariable("researcherProjectId") Long researcherProjectId)
    {
        return success(researcherprojectsService.selectResearcherprojectsByResearcherProjectId(researcherProjectId));
    }




    /**
     * 新增科研人员关联项目
     */
    @RequiresPermissions("peoplegroup:researcherprojects:add")
    @Log(title = "科研人员关联项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Researcherprojects researcherprojects)
    {
        return toAjax(researcherprojectsService.insertResearcherprojects(researcherprojects));
    }

    /**
     * 修改科研人员关联项目
     */
    @RequiresPermissions("peoplegroup:researcherprojects:edit")
    @Log(title = "科研人员关联项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Researcherprojects researcherprojects)
    {
        return toAjax(researcherprojectsService.updateResearcherprojects(researcherprojects));
    }

    /**
     * 删除科研人员关联项目
     */
    @RequiresPermissions("peoplegroup:researcherprojects:remove")
    @Log(title = "科研人员关联项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{researcherProjectIds}")
    public AjaxResult remove(@PathVariable Long[] researcherProjectIds)
    {
        return toAjax(researcherprojectsService.deleteResearcherprojectsByResearcherProjectIds(researcherProjectIds));
    }
}
